<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
      /*   ES6中引入扩展操作符(展开语法)，可以方便传入多个参数
            扩展操作符，是可以展开数组和对象的
            扩展操作符和剩余参数拥有相似的语法
            不同的是：
                剩余参数是把所有多余的参数进行收集起来转换成数组
                而扩展操作符把数组扩展成单个参数 */


        //数组展开
        let nums=[200,300,400,78,12,36];
        console.log(Math.max(nums));//不支持数组作为参数
        console.log(Math.max(200,300,400,78,12,36));
        console.log(Math.max(...nums));//会将数组扩展成单个参数

        let arr1=["aa","bb"];
        let arr2=["cc","dd"];
        let arr3=[100,...arr1,...arr2];
        console.log(arr3);

        //对象展开
        let obj1={id:1,name:"tom"};
        let obj2={name:"alice",course:"java"};
        let obj3={sex:"男",...obj1,...obj2};
        console.log(obj3);

        let objs={sex:"男",id:2,name:"lucy",course:"web"};
        let {id,sex,...attrs}=objs;
        console.log(attrs);
    </script>
</head>
<body>
    
</body>
</html>